import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
    
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]






const router = createRouter({
  history: createWebHashHistory(),
  routes
})




router.beforeEach((to, from, next) => {
  console.log(to,from);
   // 如果不是  Home路径   就跳转到 Home页面
  //  if (to.name !== 'Home') next({ name: 'Home' })
  //  //if the user is not authenticated, `next` is called twice
   next()
})










export default router
